home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PASCAL / 0195.ZIP / NUMDISKS.PAS < prev    next >
Pascal/Delphi Source File  |  1980-01-01  |  3KB  |  95 lines

  1. {@@@@@@@@@@@ copyright (C) 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@@@@@@
  2. The purchaser of these procedures and functions may include them in COMPILED
  3. programs freely, but may not sell or give away the source text.
  4.  
  5.     This is a handy application that internally resets the switches
  6.     that tell your PC how many diskette drives it has.  Certain RAM
  7.     DISK programs require switch settings to be set to the number
  8.     of physical drives PLUS the number of RAM disks you will want.
  9.     Others require that the switches show ONLY the physical drives.
  10.     NUMDISKS lets you keep your switches set for the physical drives
  11.     and reset them WITHOUT opening the PC box if need be.
  12.  
  13.     NUMDISKS works ONLY in COMPILED form.  There may be a problem if
  14.     it is activated any time except immediately after a system reset.
  15.  
  16.     You can enter "NUMDISKS <number>", where <number> is 1..4.  If you
  17.     want to skip the "press a key to reboot", add an N (or n) to your
  18.     parameter line (e.g., NUMDISKS 3n)
  19. }
  20. {$I regpack.typ}
  21. {$I equipmnt.lib}
  22. {$I reboot.lib}
  23. {$I parametr.lib}
  24. var
  25.   Equip_word : integer absolute $0040:$0010;
  26.   StrNumber  : string[3];
  27.   OldNumber, NewNumber, error  : integer;
  28.   Mask, BitChanges : integer;
  29.   Wait             : boolean;
  30. begin
  31.   StrNumber := GetParameters;
  32.   Wait      := true;
  33.   OldNumber := equipment('D');
  34.   GotoXY(1,5);
  35.   WriteLn('Switches currently set for ',OldNumber,' disk drives.');
  36.   if pos('N',StrNumber) <> 0 then
  37.     begin
  38.       delete(StrNumber,pos('N',StrNumber),1);
  39.       Wait := false;
  40.     end;
  41.   if pos('n',StrNumber) <> 0 then
  42.     begin
  43.       delete(StrNumber,pos('n',StrNumber),1);
  44.       Wait := false;
  45.     end;
  46.   while pos(' ',StrNumber) <> 0 do
  47.     delete(StrNumber,pos(' ',StrNumber),1);
  48.   val(StrNumber, NewNumber, error);
  49.   if error <> 0 then NewNumber := 5;
  50.   if not (NewNumber in [1..4]) then
  51.     begin
  52.       WriteLn('Enter new number of diskette drives (1..4)');
  53.       repeat
  54.         read(NewNumber);
  55.       until newNumber in [0..4];
  56.       WriteLn;
  57.     end;
  58.   if NewNumber = 0 then
  59.     begin
  60.       Mask     := $FF3E; { In binary, $FF3E is 1111111100111110.  When we
  61.                           AND this mask onto the Equipment flag, it
  62.                           turns OFF the bottom byte (byte #0) and bytes
  63.                           # 6 and 7.  Byte # 0 indicates whether there
  64.                           are ANY disk drives, and #6,7 say HOW many.}
  65.       BitChanges := 0
  66.     end
  67.   else
  68.     begin
  69.       Mask := $FF3F;  { ANDing $FF3F onto the Equipment Flag turns OFF
  70.                         bits # 6 and 7, the old value for number of
  71.                         disk drives.  Then we OR BitChanges onto it to
  72.                         turn ON the correct bits for the new value}
  73.       BitChanges := (((NewNumber-1) shl 6) +1);
  74.     end;
  75.   if OldNumber <> NewNumber then
  76.     begin
  77.       Equip_word := (Equip_word and Mask ) or BitChanges;
  78.       WriteLn('Changed equipment information to indicate ',NewNumber:1,' drives');
  79.       if wait then
  80.         begin
  81.           WriteLn('Press a key to reboot and activate new information.');
  82.           repeat until keypressed;
  83.         end
  84.       else
  85.         begin
  86.           write(chr(7));
  87.           WriteLn('Rebooting now.');
  88.         end;
  89.       reboot;
  90.     end
  91.   else
  92.     WriteLn('No change required.');
  93. end.
  94.  
  95.